package com.magicsoft.app.helper;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;

public class inputMethodHelper {
	public void inputMethod(Activity context) {
		if (context != null) {

			// 隐藏键盘
			InputMethodManager im = (InputMethodManager) context
					.getSystemService(Context.INPUT_METHOD_SERVICE);
			if (im != null) {
				if (context.getCurrentFocus() != null) {
					if (context.getCurrentFocus().getApplicationWindowToken() != null) {

						im.hideSoftInputFromWindow(context.getCurrentFocus()
								.getApplicationWindowToken(),
								InputMethodManager.HIDE_NOT_ALWAYS);

					}
				}

			}
		}

	}

	public void inputMethodView(Context context, View view) {
		InputMethodManager imm = (InputMethodManager) context
				.getSystemService(Context.INPUT_METHOD_SERVICE);
		if (imm != null) {
			if (view.getWindowToken() != null) {
				imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
//				imm.toggleSoftInputFromWindow(view.getWindowToken(), 0,
//						InputMethodManager.HIDE_NOT_ALWAYS);
			}

		}

	}

}
